# Contributor: Jens Pranaitis <jens@chaox.net>
# Contributor: Tom K <tomk@runbox.com>
# Contributor: kastor <kastor@fobos.org.ar>

pkgname=amap
pkgver=5.2
pkgrel=4
pkgdesc="Next-generation tool for assisting network penetration testing."
depends=('glibc' 'pcre' 'openssl')
source=(http://freeworld.thc.org/releases/$pkgname-$pkgver.tar.gz pcre.patch)
md5sums=('e3b1f5ebd24aac03aacb38ec183eb426' 'a11774428cb7e97a81107a22682d1798')
url="http://freeworld.thc.org/releases.php"
license='custom'
arch=('i686')

build() {
  cd "${srcdir}"/$pkgname-$pkgver
  # worst. buildsystem. ever.
  sed -i -e "s:etc/:share/amap/:g" amap-lib.c || return 1
  sed -i 's:/usr/local:/usr:' amap.h || return 1
  sed -i '/DATADIR/s:/etc:/share/amap:' Makefile.am || return 1
  rm -rf pcre-3.9
  patch -Np1 -i "${srcdir}"/pcre.patch || return 1
  ./configure --prefix=/usr || return 1
  sed -i "s|/man/man1|/share/man/man1|g" Makefile || return 1
  sed -i "s|-O2|$CFLAGS|g" Makefile || return 1
  sed -i "s|ln\ -s|ln\ -sf|g" Makefile || return 1
  sed -i -e '/^XLIBPATHS/s:=.*:=:' -e '/^XIPATHS=/s:=.*:=:' Makefile || return 1
  make PREFIX="${pkgdir}"/usr install || return 1
  install -D LICENCE.AMAP "${pkgdir}"/usr/share/licenses/amap/LICENSE || return 1
}
